package com.atnjupt.dao.impl;

import com.atnjupt.bean.User;
import com.atnjupt.dao.UserDao;

/**
 * @author Wizarder
 * @create 2021-05-27 16:51
 */
public class UserDaoImpl extends BaseDao<User> implements UserDao {
    @Override
    public User querForUsername(String username) {
        String sql = "select id,username,password,email from t_user where username = ?";
        User user = queryForOne(sql, username);
        return user;
    }

    @Override
    public User queryForUsernameAndPassword(String username, String password) {
        String sql = "select id,username,password,email from t_user where username = ? and password = ?";
        User user = queryForOne(sql, username, password);
        return user;
    }

    @Override
    public int SaveUser(User user) {
        String sql = "insert into t_user(username,password,email) values(?,?,?)";
        int update = update(sql, user.getUsername(),user.getPassword(), user.getEmail());
        return update;
    }
}
